package com.vpen.model.resp;

import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;
import java.util.List;


@Data
public class LicensePart implements Serializable {
    private String licenseId;
    private String licenseeName;
    private String licenseeType;
    private String assigneeName;
    private String assigneeEmail;
    private String licenseRestriction;
    private boolean checkConcurrentUse=false;
    private List<Product> products;
    private String metadata;
    private String hash;
    private int gracePeriodDays;
    private boolean autoProlongated=false;
    private boolean isAutoProlongated=false;
    private boolean trial=false;
    private boolean aiAllowed=true;

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Product implements Serializable {
        private String code;
        private String fallbackDate;
        private String paidUpTo;
        private boolean extended;
    }

    public static String buildJson(String userName, String day){
        // 构建产品列表
        List<LicensePart.Product> products = Arrays.asList(
                new LicensePart.Product("GO", day, day, false),
                new LicensePart.Product("RS0", day, day, false),
                new LicensePart.Product("DM", day, day, false),
                new LicensePart.Product("CL", day, day, false),
                new LicensePart.Product("RSU", day, day, false),
                new LicensePart.Product("RSC", day, day, true),
                new LicensePart.Product("PC", day, day, false),
                new LicensePart.Product("DS", day, day, false),
                new LicensePart.Product("RD", day, day, false),
                new LicensePart.Product("RC", day, day, false),
                new LicensePart.Product("RSF", day, day, true),
                new LicensePart.Product("RM", day, day, false),
                new LicensePart.Product("II", day, day, false),
                new LicensePart.Product("DPN", day, day, false),
                new LicensePart.Product("DB", day, day, false),
                new LicensePart.Product("DC", day, day, false),
                new LicensePart.Product("PS", day, day, false),
                new LicensePart.Product("RSV", day, day, true),
                new LicensePart.Product("WS", day, day, false),
                new LicensePart.Product("PSI", day, day, true),
                new LicensePart.Product("PCWMP", day, day, true),
                new LicensePart.Product("RS", day, day, true),
                new LicensePart.Product("DP", day, day, true),
                new LicensePart.Product("PDB", day, day, true),
                new LicensePart.Product("PRR", day, day, true)
        );

        LicensePart licenseResponse = new LicensePart();
        licenseResponse.setLicenseId("FV8EM46DQYC5AW9");
        licenseResponse.setLicenseeName(userName);
        licenseResponse.setLicenseeType("PERSONAL");
        licenseResponse.setAssigneeName("");
        licenseResponse.setAssigneeEmail("");
        licenseResponse.setLicenseRestriction("");
        licenseResponse.setProducts(products);
        licenseResponse.setMetadata("0220240702PSAX000005X");
        licenseResponse.setHash("12345678/0-541816629");
        licenseResponse.setGracePeriodDays(7);
        return JSONUtil.toJsonStr(licenseResponse);
    }


}
